<template>
  <div id="app">
    <!-- 粒子背景 -->
    <div id="particles-js"></div>

    <header>
      <div class="logo">
        <div class="logo-icon">
          <i class="fas fa-gamepad"></i>
        </div>
        <div class="logo-text">幻影联机大厅</div>
      </div>

      <div class="nav-buttons">
        <button class="nav-btn"><i class="fas fa-home"></i> 首页</button>
        <button class="nav-btn"><i class="fas fa-comments"></i> 社区</button>
        <button class="nav-btn"><i class="fas fa-cog"></i> 设置</button>
      </div>

      <div class="user-info">
        <div class="user-avatar">S</div>
        <div>
          <div class="player-name">ShadowNinja</div>
          <div class="player-level"><i class="fas fa-shield-alt"></i> 等级 27</div>
        </div>
      </div>
    </header>

    <div class="main-content">
      <!-- 左侧：在线玩家 -->
      <div class="panel left-panel">
        <div class="panel-header">
          <div class="panel-title"><i class="fas fa-users"></i> 在线玩家 ({{ players.length }})</div>
          <div class="player-level"><i class="fas fa-signal"></i> 良好</div>
        </div>
        <div class="panel-content">
          <div class="player-list">
            <div class="player-card" v-for="player in players" :key="player.id">
              <div class="player-avatar" :style="{ background: player.avatarColor }">
                {{ player.avatarText }}
                <div class="player-status" :class="player.status === '在线' ? 'status-online' : 'status-ingame'"></div>
              </div>
              <div class="player-info">
                <div class="player-name">{{ player.name }}</div>
                <div class="player-level"><i class="fas fa-shield-alt"></i> 等级 {{ player.level }}</div>
              </div>
            </div>
          </div>
        </div>
      </div>

      <!-- 中间：房间列表 -->
      <div class="panel center-panel">
        <div class="panel-header">
          <div class="panel-title"><i class="fas fa-door-open"></i> 房间列表</div>
          <div class="player-level"><i class="fas fa-sync-alt"></i> 实时更新</div>
        </div>
        <div class="panel-content">
          <div class="room-controls">
            <div class="search-box">
              <i class="fas fa-search"></i>
              <input type="text" placeholder="搜索房间..." />
            </div>
            <button class="create-btn"><i class="fas fa-plus"></i> 创建房间</button>
          </div>

          <div class="room-list">
            <div class="room-card" v-for="room in rooms" :key="room.id">
              <div class="room-header">
                <div class="room-name">{{ room.name }}</div>
                <div class="room-mode">{{ room.mode }}</div>
              </div>

              <div class="room-details">
                <div class="room-detail"><i class="fas fa-user"></i> {{ room.creator }}</div>
                <div class="room-detail"><i class="fas fa-map"></i> {{ room.map }}</div>
              </div>

              <div class="room-players">
                <div class="player-dot" v-for="(color, index) in room.playerColors" :key="index" :style="{ background: color }">
                  {{ index < room.players - 1 ? "" : "+" + (room.players - 4) }}
                </div>
              </div>

              <div class="room-status">
                <div class="room-player-count">{{ room.players }} / {{ room.maxPlayers }} 玩家</div>
                <button class="join-btn">加入房间</button>
              </div>
            </div>
          </div>
        </div>
      </div>

      <!-- 右侧：房间详情 -->
      <div class="panel right-panel">
        <div class="panel-header">
          <div class="panel-title"><i class="fas fa-info-circle"></i> 房间详情</div>
          <div class="player-level"><i class="fas fa-lock-open"></i> 公开</div>
        </div>
        <div class="panel-content">
          <div class="current-room">
            <div class="room-banner">竞技场 - 夺旗模式</div>

            <div class="room-info">
              <div class="info-row">
                <span class="info-label">房间名称:</span>
                <span class="info-value">夺旗竞技场 #3</span>
              </div>
              <div class="info-row">
                <span class="info-label">创建者:</span>
                <span class="info-value">DragonSlayer</span>
              </div>
              <div class="info-row">
                <span class="info-label">游戏模式:</span>
                <span class="info-value">团队夺旗</span>
              </div>
              <div class="info-row">
                <span class="info-label">地图:</span>
                <span class="info-value">遗忘神庙</span>
              </div>
              <div class="info-row">
                <span class="info-label">玩家:</span>
                <span class="info-value">6 / 8</span>
              </div>
              <div class="info-row">
                <span class="info-label">状态:</span>
                <span class="info-value">等待中</span>
              </div>
            </div>

            <button class="ready-btn"><i class="fas fa-check"></i> 准备就绪</button>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>
<script setup>
import { onMounted, ref } from "vue";

// 在线玩家
const players = ref([
  { id: 1, name: "Phantom", level: 35, avatarColor: "linear-gradient(135deg, #4e6fff, #a45fff)", avatarText: "P", status: "游戏中" },
  { id: 2, name: "Luna", level: 28, avatarColor: "linear-gradient(135deg, #ff6b6b, #ffa36c)", avatarText: "L", status: "在线" },
  { id: 3, name: "CyberWolf", level: 42, avatarColor: "linear-gradient(135deg, #4cff9d, #00c9a7)", avatarText: "C", status: "在线" },
  { id: 4, name: "Neo", level: 31, avatarColor: "linear-gradient(135deg, #b47cff, #ff7ce5)", avatarText: "N", status: "游戏中" },
  { id: 5, name: "Raven", level: 19, avatarColor: "linear-gradient(135deg, #ff7ce5, #ff6b6b)", avatarText: "R", status: "在线" },
  { id: 6, name: "Vortex", level: 50, avatarColor: "linear-gradient(135deg, #00c9a7, #4e6fff)", avatarText: "V", status: "游戏中" },
  { id: 7, name: "Spectral", level: 23, avatarColor: "linear-gradient(135deg, #ffa36c, #ffde59)", avatarText: "S", status: "在线" },
  { id: 8, name: "Blaze", level: 37, avatarColor: "linear-gradient(135deg, #ffde59, #ff7ce5)", avatarText: "B", status: "在线" }
]);

// 房间列表
const rooms = ref([
  { id: 1, name: "夺旗竞技场", mode: "团队竞技", creator: "Phantom", map: "遗忘神庙", players: 6, maxPlayers: 8, playerColors: ["#4e6fff", "#ff6b6b", "#4cff9d", "#b47cff"] },
  { id: 2, name: "生存挑战", mode: "生存模式", creator: "CyberWolf", map: "末日废墟", players: 3, maxPlayers: 4, playerColors: ["#00c9a7", "#ffa36c", "#ffde59"] },
  { id: 3, name: "速战速决", mode: "死亡竞赛", creator: "Luna", map: "霓虹都市", players: 8, maxPlayers: 8, playerColors: ["#4e6fff", "#ff7ce5", "#ff6b6b", "#4cff9d"] },
  { id: 4, name: "新手训练营", mode: "教程", creator: "Blaze", map: "训练基地", players: 2, maxPlayers: 4, playerColors: ["#ffde59", "#b47cff"] },
  { id: 5, name: "巅峰对决", mode: "1v1", creator: "Vortex", map: "决斗场", players: 1, maxPlayers: 2, playerColors: ["#ff6b6b"] },
  { id: 6, name: "夺宝奇兵", mode: "夺宝模式", creator: "Raven", map: "古代遗迹", players: 5, maxPlayers: 6, playerColors: ["#00c9a7", "#4e6fff", "#ffa36c", "#b47cff"] }
]);

// 初始化粒子背景
onMounted(() => {
  particlesJS("particles-js", {
    particles: {
      number: { value: 80, density: { enable: true, value_area: 800 } },
      color: { value: "#4e6fff" },
      shape: { type: "circle" },
      opacity: { value: 0.3, random: true },
      size: { value: 3, random: true },
      line_linked: {
        enable: true,
        distance: 150,
        color: "#4e6fff",
        opacity: 0.1,
        width: 1
      },
      move: {
        enable: true,
        speed: 1,
        direction: "none",
        random: true,
        straight: false,
        out_mode: "out",
        bounce: false
      }
    },
    interactivity: {
      detect_on: "canvas",
      events: {
        onhover: { enable: true, mode: "grab" },
        onclick: { enable: true, mode: "push" },
        resize: true
      }
    },
    retina_detect: true
  });
});
</script>
<style scoped>
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
}

body {
  background: linear-gradient(135deg, #0f0c29, #302b63, #24243e);
  color: #e0e0ff;
  min-height: 100vh;
  overflow-x: hidden;
}

#app {
  max-width: 1600px;
  margin: 0 auto;
  padding: 20px;
  position: relative;
}

/* 粒子背景容器 */
#particles-js {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: -1;
}

/* 顶部标题和导航 */
header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 0;
  border-bottom: 2px solid rgba(80, 120, 255, 0.3);
  margin-bottom: 30px;
  position: relative;
}

.logo {
  display: flex;
  align-items: center;
  gap: 15px;
}

.logo-icon {
  font-size: 2.5rem;
  color: #4e6fff;
  text-shadow: 0 0 15px rgba(78, 111, 255, 0.7);
}

.logo-text {
  font-size: 2.2rem;
  font-weight: 800;
  background: linear-gradient(90deg, #6a9eff, #b47cff);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  letter-spacing: 1px;
}

.nav-buttons {
  display: flex;
  gap: 15px;
}

.nav-btn {
  background: rgba(30, 30, 60, 0.7);
  border: 1px solid rgba(100, 150, 255, 0.3);
  color: #a8c1ff;
  padding: 10px 20px;
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  gap: 8px;
}

.nav-btn:hover {
  background: rgba(60, 80, 160, 0.5);
  box-shadow: 0 0 15px rgba(80, 120, 255, 0.4);
  transform: translateY(-2px);
}

.user-info {
  display: flex;
  align-items: center;
  gap: 12px;
}

.user-avatar {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  background: linear-gradient(135deg, #4e6fff, #a45fff);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  font-weight: bold;
  border: 2px solid rgba(255, 255, 255, 0.2);
}

/* 主要内容区域 */
.main-content {
  display: grid;
  grid-template-columns: 1fr 2fr 1fr;
  gap: 25px;
  margin-top: 20px;
}

/* 面板通用样式 */
.panel {
  background: rgba(20, 20, 40, 0.7);
  border-radius: 15px;
  border: 1px solid rgba(100, 150, 255, 0.2);
  backdrop-filter: blur(10px);
  box-shadow: 0 10px 30px rgba(0, 5, 30, 0.5);
  overflow: hidden;
}

.panel-header {
  padding: 20px;
  border-bottom: 1px solid rgba(100, 150, 255, 0.2);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.panel-title {
  font-size: 1.4rem;
  font-weight: 700;
  color: #8fb3ff;
  display: flex;
  align-items: center;
  gap: 10px;
}

.panel-content {
  padding: 20px;
  height: calc(100% - 65px);
}

/* 在线玩家面板 */
.player-list {
  display: flex;
  flex-direction: column;
  gap: 15px;
  max-height: 700px;
  overflow-y: auto;
  padding-right: 8px;
}

.player-card {
  background: rgba(40, 45, 80, 0.5);
  border-radius: 12px;
  padding: 15px;
  display: flex;
  align-items: center;
  gap: 15px;
  transition: all 0.3s ease;
  border: 1px solid rgba(100, 150, 255, 0.1);
}

.player-card:hover {
  background: rgba(60, 70, 130, 0.6);
  transform: translateX(5px);
  border-color: rgba(100, 150, 255, 0.3);
}

.player-avatar {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  font-size: 1.2rem;
  position: relative;
}

.player-status {
  position: absolute;
  bottom: 0;
  right: 0;
  width: 15px;
  height: 15px;
  border-radius: 50%;
  border: 2px solid rgba(20, 20, 40, 0.7);
}

.status-online {
  background: #4cff9d;
  box-shadow: 0 0 8px #4cff9d;
}

.status-ingame {
  background: #ff6b6b;
  box-shadow: 0 0 8px #ff6b6b;
}

.player-info {
  flex: 1;
}

.player-name {
  font-weight: 600;
  margin-bottom: 5px;
  color: #e0e0ff;
}

.player-level {
  font-size: 0.85rem;
  color: #a8c1ff;
  display: flex;
  align-items: center;
  gap: 5px;
}

/* 房间列表面板 */
.room-controls {
  display: flex;
  gap: 15px;
  margin-bottom: 20px;
}

.search-box {
  flex: 1;
  position: relative;
}

.search-box input {
  width: 100%;
  padding: 12px 15px 12px 45px;
  border-radius: 10px;
  background: rgba(30, 35, 70, 0.7);
  border: 1px solid rgba(100, 150, 255, 0.3);
  color: #e0e0ff;
  font-size: 1rem;
}

.search-box i {
  position: absolute;
  left: 15px;
  top: 12px;
  color: #8fb3ff;
}

.create-btn {
  background: linear-gradient(135deg, #4e6fff, #a45fff);
  color: white;
  border: none;
  padding: 12px 25px;
  border-radius: 10px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  gap: 8px;
}

.create-btn:hover {
  transform: translateY(-3px);
  box-shadow: 0 5px 20px rgba(78, 111, 255, 0.4);
}

.room-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 20px;
}

.room-card {
  background: linear-gradient(135deg, rgba(40, 45, 80, 0.7), rgba(30, 35, 70, 0.7));
  border-radius: 12px;
  padding: 20px;
  border: 1px solid rgba(100, 150, 255, 0.2);
  transition: all 0.3s ease;
  position: relative;
  overflow: hidden;
}

.room-card::before {
  content: "";
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: radial-gradient(circle, rgba(100, 150, 255, 0.1) 0%, transparent 70%);
  transform: rotate(30deg);
  opacity: 0;
  transition: opacity 0.5s ease;
}

.room-card:hover {
  transform: translateY(-5px);
  border-color: rgba(100, 150, 255, 0.4);
  box-shadow: 0 10px 25px rgba(0, 5, 30, 0.6);
}

.room-card:hover::before {
  opacity: 1;
}

.room-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 15px;
}

.room-name {
  font-size: 1.2rem;
  font-weight: 700;
  color: #8fb3ff;
}

.room-mode {
  background: rgba(100, 150, 255, 0.2);
  padding: 5px 10px;
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 600;
}

.room-details {
  display: flex;
  gap: 15px;
  margin-bottom: 15px;
}

.room-detail {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 0.9rem;
  color: #a8c1ff;
}

.room-players {
  display: flex;
  align-items: center;
  margin-bottom: 15px;
}

.player-dot {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  margin-right: -10px;
  border: 2px solid rgba(20, 20, 40, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  font-weight: bold;
}

.room-status {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 15px;
}

.room-player-count {
  font-size: 0.9rem;
  color: #a8c1ff;
}

.join-btn {
  background: rgba(100, 150, 255, 0.2);
  color: #8fb3ff;
  border: 1px solid rgba(100, 150, 255, 0.3);
  padding: 8px 20px;
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
}

.join-btn:hover {
  background: rgba(100, 150, 255, 0.4);
  transform: translateY(-2px);
}

/* 房间详情面板 */
.current-room {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.room-banner {
  height: 120px;
  background: linear-gradient(90deg, #4e6fff, #a45fff);
  border-radius: 12px;
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  font-weight: 800;
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
  position: relative;
  overflow: hidden;
}

.room-banner::after {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(45deg, transparent 50%, rgba(255, 255, 255, 0.1) 50%);
  background-size: 20px 20px;
}

.room-info {
  margin-bottom: 25px;
}

.info-row {
  display: flex;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid rgba(100, 150, 255, 0.1);
}

.info-label {
  color: #8fb3ff;
  font-weight: 600;
}

.info-value {
  color: #e0e0ff;
}

.ready-btn {
  background: linear-gradient(135deg, #4cff9d, #00c9a7);
  color: #0a1f2a;
  border: none;
  padding: 15px;
  border-radius: 12px;
  font-weight: 800;
  font-size: 1.1rem;
  cursor: pointer;
  transition: all 0.3s ease;
  margin-top: auto;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.ready-btn:hover {
  transform: translateY(-3px);
  box-shadow: 0 5px 20px rgba(76, 255, 157, 0.4);
}

/* 响应式调整 */
@media (max-width: 1200px) {
  .main-content {
    grid-template-columns: 1fr 2fr;
  }
  .right-panel {
    grid-column: span 2;
    margin-top: 25px;
  }
}

@media (max-width: 768px) {
  .main-content {
    grid-template-columns: 1fr;
  }
  .right-panel {
    grid-column: span 1;
  }
  .room-list {
    grid-template-columns: 1fr;
  }
  header {
    flex-direction: column;
    gap: 20px;
  }
  .nav-buttons {
    width: 100%;
    justify-content: center;
  }
}
</style>
